package com.zqs.compareface.utils.impl;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONObject;

/**
 * @Program: 百度API判断结果输出
 * @Description:
 * @Author: zqs
 * @Create： 2021-08-10-15:13
 */
public class ResultUtil {
    public static boolean isOrNot(JSONObject compareResults){
        Log log = LogFactory.getLog(ResultUtil.class);
        if (JsonUtil.getJson(compareResults) instanceof Float
                || JsonUtil.getJson(compareResults) instanceof Double
                || JsonUtil.getJson(compareResults) instanceof Integer ) {

            Object resultStr = JsonUtil.getJson(compareResults);
            Double result = Double.valueOf(resultStr.toString());
            log.info("人脸相似度："+resultStr);
            if (result >60D){
                return true;
            }
        } else if (JsonUtil.getJson(compareResults) instanceof Boolean) {
            Boolean result = (Boolean) JsonUtil.getJson(compareResults);
            return result;
        } else if (null == JsonUtil.getJson(compareResults)) {
            //TODO 空指针异常处理 暂时返回false
            log.warn("没有检测到人脸");
            return false;
        }
        return false;
    }
}
